// Author: Domien Nowicki

#include "Move.h"

#include <sstream>
#include <iomanip>

using namespace std;

Move::Move(): map(0)
{
}

Move::Move(Map* newMap, const std::string& newLand, const std::string& newProvince, Color newColor): map(newMap), land(newLand), province(newProvince), color(newColor)
{
}

Move::Move(const Move& rhs): map(rhs.map), land(rhs.land), province(rhs.province), color(rhs.color)
{
	
}

Move::~Move()
{
}

Color Move::GetColor() const
{
	return color;
}

void Move::SetColor(Color newColor)
{
	color = newColor;
}

void Move::SetMap(Map *newMap)
{
	map = newMap;
}

void Move::SetLand(const std::string& newLand)
{
	land = newLand;
}

void Move::SetProvince(const std::string& newProvince)
{
	province = newProvince;
}


Map* Move::GetMap() const
{
	return map;
}

const std::string& Move::GetLand() const
{
	return land;
}

const std::string& Move::GetProvince() const
{
	return province;
}

// Convert the move to a textual string
std::string Move::ToString() const
{
	ostringstream s;

	// <Province> <color in hex>.
	s << GetProvince() << " 0x" << setw(6) << uppercase << hex << setfill('0') << GetColor().GetColorValue() << ".";
	
	// Return the string
	return s.str();
}

Move& Move::operator=(const Move& rhs)
{
	if (this != &rhs)
	{
		SetColor(rhs.color);
		SetMap(rhs.map);
		SetLand(rhs.land);
		SetProvince(rhs.province);
	}

	return *this;
}

